package com.top.art.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.top.art.annotation.PermissionLimit;
import com.top.art.entity.Constants;
import com.top.art.service.IConstantsService;
import com.top.art.vo.ResVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: huangyixin
 * @create: 2020/10/14 22:50
 **/
@RestController
@RequestMapping("/constants")
public class ConstantController {

    @Autowired
    IConstantsService iConstantsService;

    @GetMapping(value = "/getSponsor")
    @PermissionLimit(limit = false)
    public ResVO getSponsor() {
        Constants cons = iConstantsService.getOne(Wrappers.<Constants>lambdaQuery().eq(Constants::getLockKey, "sponsor"));
        if (cons != null) {
            return new ResVO(cons.getLockValue());
        } else {
            return new ResVO("TOP公司");
        }
    }
}
